package com.anjie.powerproject.repository;

import com.anjie.powerproject.entity.StrategyTemp;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface StrategyTempRepository extends JpaRepository<StrategyTemp, Integer> {

    @Query(nativeQuery = true, value = "select * from strategy_temp where type = :type and ((DATE_FORMAT(start_time, '%Y-%m-%d') = :time and DATE_FORMAT(start_time, '%H') < 23) or (DATE_FORMAT(start_time, '%Y-%m-%d') = DATE_SUB(:time, INTERVAL 1 DAY) and DATE_FORMAT(start_time, '%H') >= 23))")
    List<StrategyTemp> findStrategyTempsByTypeAndDate(@Param("type") Integer type, @Param("time") String time);

}
